#ifndef __BSP_I2C_H__
#define __BSP_I2C_H__


#include "config.h"


#if I2C_ENABLE

#define I2C_SCL_APBxClock_FUN    	RCC_APB2PeriphClockCmd
#define I2C_SCL_APBxClock_CLK    	RCC_APB2Periph_GPIOA		
#define I2C_SCL_GPIO_PORT           GPIOA
#define I2C_SCL_GPIO_PIN            GPIO_Pin_2 // SCL的引脚

#define I2C_SDA_APBxClock_FUN    	RCC_APB2PeriphClockCmd
#define I2C_SDA_APBxClock_CLK    	RCC_APB2Periph_GPIOA	
#define I2C_SDA_GPIO_PORT           GPIOA
#define I2C_SDA_GPIO_PIN            GPIO_Pin_3 // SDA的引脚

#define I2C_SCL_LOW    GPIO_ResetBits(I2C_SCL_GPIO_PORT,I2C_SCL_GPIO_PIN)
#define I2C_SCL_HIGH   GPIO_SetBits(I2C_SCL_GPIO_PORT,I2C_SCL_GPIO_PIN)


#define I2C_SDA_LOW    GPIO_ResetBits(I2C_SDA_GPIO_PORT,I2C_SDA_GPIO_PIN)
#define I2C_SDA_HIGH   GPIO_SetBits(I2C_SDA_GPIO_PORT,I2C_SDA_GPIO_PIN)


#define I2C_SDA_READ   GPIO_ReadInputDataBit(I2C_SDA_GPIO_PORT,I2C_SDA_GPIO_PIN)

#define I2C_ACK   0
#define I2C_NOACK 1



void I2cGpioInit(void);
void I2cStart(void);
void I2cStop(void);
void I2cAck(void);
void I2cNoAck(void);
unsigned char I2cReadAck(void);
void I2cWriteByte(unsigned char ByteData);
void I2cReadByte(unsigned char *ByteData);

#endif


#endif



